﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>热表转工排产计划接收</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
</head>
<body>
    <div style="margin:0px 1px 0px 0px">
        <div id="mainDiv" style="width: 100%">
            <div class="panelSection">
                <div class="easyui-panel " title="查询区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                    <form id="queryForm" action="">
                    <div style="margin: 3px 0px 3px 3px">
                        <div style="float: left">
                            <div class="divLabel" style="margin-bottom: 5px; color: red; font-weight: bold">
                                扫描流水卡：</div>
                            <input id="txtScanContainer" name="scanContainer" class="easyui-textbox" type="text"
                                style="width: 120px; height: 22px" />
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px; color: red; font-weight: bold">
                                扫描订单号：</div>
                            <input id="txtScanOrder" name="scanOrder" class="easyui-textbox" type="text" style="width: 120px;
                                height: 22px" />
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px">
                                件号：</div>
                            <input id="txtProductName" name="productName" class="easyui-textbox" style="width: 120px;
                                height: 22px" />
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px">
                                批次号：</div>
                            <input id="txtContainerName" name="containerName" class="easyui-textbox" style="width: 120px;
                                height: 22px" />
                        </div>
                        <div style="float: left;margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px;">
                                计划开始日期：</div>
                            <input id="txtPlanStartDate" name="planStartDate" class="easyui-datebox" type="text"
                                style="width: 120px; height: 22px"  data-options='editable:false' />
                            -
                            <input id="txtPlanEndDate" name="planEndDate" class="easyui-datebox" type="text"
                                style="width: 120px; height: 22px;"  data-options='editable:false'/>
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px">
                                确认状态：</div>
                            <select style='width: 80px; height: 22px' id='selStatus' name="status" data-options='value:1,editable:false,panelHeight:100'
                                class='easyui-combobox'>
                                <option value="1">已确认</option>
                                <option value="2">已接收</option>
                            </select>
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <button id="btnSearch" type="button" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                                width: 80px;">
                                查询</button>
                            <button id="btnReset" type="button" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                                width: 50px;">
                                重置</button>
                        </div>
                        <div style="clear: both">
                        </div>
                    </div>
                    </form>
                </div>
            </div>
            <div class="panelSection">
                <div class="easyui-panel " title="结果区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                    <div style="margin: 3px 0px 3px 3px; width: 98%">
                        <table id="gdApsPlanInfo" class="easyui-datagrid" style="width: 100%; height: 350px"
                            data-options="rownumbers:true">
                        </table>
                        <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['list','first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: true,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                    pageList:[5,10,20,50,100,200],
                    buttons:[{
                            iconCls:'',
                            text:'Go',
                            group:'paging-tail-btns',
                            id:'pageGo'
                    }]  
                ">
                        </div>
                    </div>
                </div>
            </div>
            <div class="panelSection">
                <div class="easyui-panel " title="按钮区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                    <div style="margin: 3px 0px 3px 3px">
                        <button id="btnReceive" class="easyui-linkbutton" type="button" style="width: 80px;
                            height: 26px;">
                            转出接收</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：zhangrj
    日期：2024-11-15
    描述：热表转工计划排产接收js
    */
    var page = {
        pageTotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        url: getRootPath() + "/Ashx/ApsHandler/RbApsPlanShipConfirmHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        //页面事件绑定
        bind: function () {
            //排产列表加载
            $("#gdApsPlanInfo").datagrid({
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pageTotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'MFGORDERNAME', title: '订单号', width: 150 },
                 { field: 'CONTAINERNAME', title: '批次号', width: 150 },
                 { field: 'DESCRIPTION', title: '零件名称', width: 150 },
                 { field: 'WORKFLOWINFO', title: '工艺版次', width: 150 },
                 { field: 'WORKFLOWSTEPNAME', title: '工序', width: 120 },
                 { field: 'STEPNAME', title: '工步', width: 80 },
                 { field: 'CREATEDATE', title: '计划生成时间', width: 100,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD');
                         }
                     }
                 },
                 { field: 'STARTTIME', title: '计划开始时间', width: 150,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
                         }
                     }
                 },
                 { field: 'ENDTIME', title: '计划结束时间', width: 150,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
                         }
                     }
                 },
                 { field: 'CONFIRMEMPNAME', title: '转出人', width: 100 },
                 { field: 'CONFIRMDATE', title: '转出时间', width: 150,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
                         }
                     }
                 },
                 { field: 'RECEIVEEMPNAME', title: '接收人', width: 100 },
                 { field: 'SHIPRECEIVEDATE', title: '接收时间', width: 150,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
                         }
                     }
                 },
                 { field: 'SHIPSTATUS', title: '确认状态', width: 60, formatter: function (value, row, index) {
                     if (value === "0") {
                         return "未确认";
                     } else if (value === "1") {
                         return "已确认";
                     }
                     else {
                         return "已接收";
                     }
                 }
                 }
                ]]
            });
            //查询按钮
            $('#btnSearch').on("click", function () {
                page.clearPage(false, true, true);
                page.pageNumber = 1;
                page.searchData();
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    page.clearPage(false, true, true);
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.searchData();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                page.clearPage(false, true, true);
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.searchData();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.clearPage(true, true, true);
                page.pageNumber = 1; page.pageTotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pageTotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            });
            //状态下拉选择
            $('#selStatus').combobox({
                onSelect: function (record) {
                    clearEasyuiDataGrid("gdApsPlanInfo");
                    switch (record.value) {
                        case "1":
                            $("#btnReceive").show();
                            break;
                        case "2":
                            $("#btnReceive").hide();
                            break;
                        default:
                    }
                }
            });
            //扫描批次事件
            $('#txtScanContainer').textbox({
                onChange: function (n, o) {
                    page.pageNumber = 1;
                    page.searchData();
                }
            });
            //扫描批次事件
            $('#txtScanOrder').textbox({
                onChange: function (n, o) {
                    page.pageNumber = 1;
                    page.searchData();
                }
            });
            //接收
            $('#btnReceive').on("click", function () {
                page.clearPage(false, false, true);
                page.saveReceive();
            });
        },
        //查询
        searchData: function () {
            var params = {
                pageSize: page.pageSize,
                pageIndex: page.pageNumber
            };
            var datas = $("#queryForm").serializeArray();
            $.each(datas, function () {
                params[this.name] = this.value;
            });
            var formData = {
                action: "GetApsPlanShipOutDatas",
                params: JSON.stringify(params)
            };
            page.post(page.url, formData, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.pageTotal = res.RowCount;
                $("#gdApsPlanInfo").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
            });
        },
        //保存接收
        saveReceive: function () {
            page.disableBtn();
            var selected = $("#gdApsPlanInfo").datagrid("getChecked");
            if (selected.length === 0) {
                page.enableBtn();
                displayMessage("请选择数据", false);
                return false;
            }
            var datas = selected.map(function (item) {
                return {
                    apsPlanDetailId: item.APSPLANDETAILID,
                    containerId: item.CONTAINERID,
                    containerName: item.CONTAINERNAME
                }
            });
            var formData = {
                action: "SaveRbApsPlanShipReceive",
                datas: JSON.stringify(datas)
            };
            page.post(page.url, formData, true, function (res) {
                if (res.Result) {
                    page.searchData();
                }
                page.enableBtn();
                displayMessage(res.Message, res.Result);
            });
        },
        //禁用页面按钮
        disableBtn: function () {
            $("body").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('disable');
            });
        },
        //启用页面按钮
        enableBtn: function () {
            $("body").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('enable');
            });
        },
        //清除页面（查询区域，列表区域，填写区域，是否清空消息）
        clearPage: function (query, list, msg) {
            if (query) {
                $("#queryForm").find(".easyui-textbox").each(function () {
                    $(this).textbox("clear");
                });
                $("#queryForm").find(".easyui-datebox").each(function () {
                    $(this).datebox("clear");
                });
                $("#selStatus").combobox("setValue", "1");
            }
            if (list) {
                clearEasyuiDataGrid("gdApsPlanInfo"); //清空列表
            }
            if (msg) {
                clearMessage();
            }
        },
        //post数据（路径，参数，是否异步，成功返回方法）
        post: function (url, param, async, callback) {
            $.ajax({
                type: "Post",
                url: url,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                    page.enableBtn();
                }
            });
        }
    }
    $(function () {
        page.init();
    });
</script>
